module CurrentUserSpecHelper
  def fake_current_user role=nil
    store_user_state CurrentUserHelper::build_user_state_object('username')
    
    user = User.new :username => 'username'

		if role
			user.roles << role
		end

    person = Person.new
    user.person = person        

    controller.stub!(:current_user).and_return(user)
    user
  end

	def fake_current_user_as_admin
		fake_current_user Role.new(:name => Role::Roles::ADMIN)
	end

  def store_user_state(username)
    # user_state = ApplicationController::UserState.new(username)
    user_state = CurrentUserHelper::UserState.new(username)

    controller.store_user_state user_state
  end
end